Skip to content

Values will occasionally NaN when width and height cannot be obtained fr...#59

Open
DotFreelance wants to merge 1 commit intostowball:masterfrom
DotFreelance:master
Open

Values will occasionally NaN when width and height cannot be obtained fr...#59
DotFreelance wants to merge 1 commit intostowball:masterfrom
DotFreelance:master

Conversation

@DotFreelance
Copy link

...om ‘item’ object. Added code to check values and use this.width/this.height instead.

… from ‘item’ object. Added code to check values and use this.width/this.height instead.
@DotFreelance
Copy link
Author

When importing this library into a rather large project, found that occasionally the w and h variables would be 0, resulting in a divide by zero and an infinity/NaN result which completely disables the image maps. Adding the 4 lines of code corrected this problem. The code will not supersede what already exists.

@DotFreelance DotFreelance reopened this Apr 9, 2014
@coreyleelarson
Copy link

This pull request should really be accepted. I had this exact problem as well and this fix worked.

@jeremylcarter
Copy link

I used naturalHeight and naturalWidth but essentially its the same fix. Thanks for the pointers!

if(!w)
w = this.width;
if(!h)
h = this.height;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was a bug like the one below, but thanks to you, I solved it. thank you!

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants